package com.fastloan.mgt.application.approve.controller;

import com.fastloan.mgt.application.approve.model.ApplicationApproveFile;
import com.fastloan.mgt.application.approve.service.ApplicationApproveFileService;
import com.fastloan.mgt.log.aspect.SystemLog;
import com.kawins.base.baseabs.BaseController;
import com.kawins.result.ResultTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author chenkai
 *         createTime 2017-11-2017/11/10 9:42
 */
@RestController
@RequestMapping("/api/web/applicationApproveFile")
public class ApplicationApproveFileController extends BaseController<ApplicationApproveFile> {
    @Autowired
    private ApplicationApproveFileService applicationApproveFileService;


    /**
     * 上传审批文件
     * @param appApproveId
     * @param files
     * @return
     */
    @PostMapping("/{appApproveId}")
    @SystemLog(description="上传审批文件")
    public ResultTo uploadApproveFile(@PathVariable String appApproveId, MultipartFile[] files) {
        return new ResultTo().setData(applicationApproveFileService.uploadApproveFiles(appApproveId, files));
    }

    /**
     * 删除审批文件
     * @param appApproveId
     * @param fileId
     * @return
     */
    @DeleteMapping("/{appApproveId}/{fileId}")
    @SystemLog(description=" 删除审批文件")
    public ResultTo uploadApproveFile(@PathVariable String appApproveId,@PathVariable String fileId) {
        return new ResultTo().setData(applicationApproveFileService.deleteApproveFiles(appApproveId, fileId));
    }


}
